<template>
 <kb-layout>
  
	<view class="u-page" >

	<view v-if="sechouse.length>0" >
		<view class="house-items-ul">
			<view class="ul-li" v-for="(item, index) in sechouse" :key="index">
			
			 <kb-house-item  :house="item"></kb-house-item>
			
			</view>	
		</view>
	</view>
	 
  <up-empty v-if="isempty" mode="data" text="暂无房源"  :icon="ee.webUrl+'/images/empty/nodata.png'" > </up-empty>
	
	 
	<view v-if="(!isempty && nomore)" class="findmore"> 已经到底线了</view>
	
	
	</view>
	<kb-footer :color="ee.primayColor" ></kb-footer>
	
 
</kb-layout>
</template>

<script>
	import util from "@/common/tools/utils.js";
	export default {
		data() {
			return {
				page:1,
				pagesize:10, 
				sechouse:[], 
				total:0,
				shotips: undefined,
				nomore:true,
			}
		},
		computed:{
			isempty(){
				return  this.total==0;
			} 
		},
		onLoad() {
			this.fetchHouse();
		},
		methods: {
			fetchHouse( ){
				
				uni.showLoading({title: 'Loading...'});				
				
				util.getModuleData('favorite/feed',
					{   
						page: this.page  ,
						pagesize: this.pagesize,
					}
				).then(
					(ret) => {
						console.log(ret)	 
						if(ret.items.length>0){								 
							this.page = this.page +1;							
							this.total = ret.total;					
							this.sechouse = this.sechouse.concat(ret.items);
						}  
						uni.hideLoading();
						
					}
				) 
			}
		},
		onReachBottom() {
			if(this.total  && this.total < this.page * this.pagesize) 
				this.nomore = true;
			else
			   this.total >1 &&  this.fetchHouse();
			
			this.shotips = false;	
			return true;
			 
		},
	}
</script>

<style lang="scss">
.u-page{
	margin: 10px;
	border-radius: 10px;
	background-color: #fff;
	padding: 10px;
}
</style>
